/**************************************************
ANES Demographics
****************************************************/


/******************************
ANES 2016
*******************************/

clear 
cd "C:\Users\jar68\OneDrive\Ongoing Work\Party Cues and Suspicion Paper\Final Datavserse\Online Appendix A"
log using "anes_demographics_log.log"
use "anes_timeseries_2016.dta"

set more off

***Survey Weights
svyset [pweight=V160102], strata(V160201) psu(V160202)


***Gender
recode V161342 (1=0 "male") (2=1 "female") (else=.), gen(gender)
svy: tab gender

***Age
recode V161267 (-9 -8 =.), gen(age)
gen age_cat = .
	replace age_cat = 1 if age >=18 & age <= 24
	replace age_cat = 2 if age >=25 & age <= 34
	replace age_cat = 3 if age >=35 & age <= 44
	replace age_cat = 4 if age >=45 & age <= 54
	replace age_cat = 5 if age >=55 & age <= 64
	replace age_cat = 6 if age >=65

svy: mean age
svy: tab age_cat

***Education
recode V161270 (-9 =.) (1 2 3 4 5 6 7 8 = 1 "No HS") ///
	           (9 = 2 "HS Grad") (10 11 12 = 3 "Some College") ///
			   (13 = 4 "BA") (14 15 16 = 5 "Post-BA") (90 95=.), gen(educ)
			   
svy: tab educ

***Race/Ethnicity
recode V161310x (-9=.) (1=1 "White" ) (2=2 "Black") (3=3 "Asian") (5=4 "Hispanic")  (4 6 = 5 "Other"), gen(race_eth)
svy: tab race_eth

***Household Income
recode V161361x (-9 -5 =.), gen(income)

summ income, detail

***PID
recode V161158x (-9 -8 =.), gen(pid)
recode pid (1 2 3 = 1 "Democrat" ) (4=2 "Independent") (5 6 7 = 3 "Republican"), gen(pid_3)

svy: mean pid
svy: tab pid_3


***Symbolic Ideology
recode V161126 (-9 -8  99 =.), gen(ideol)
recode ideol (1 2 3 = 1 "Liberal" ) (4 = 2 "Moderate") (5 6 7 = 3 "Liberal"), gen(ideol_3)

svy: mean ideol
svy: tab ideol_3



/******************************
ANES 2018
*******************************/

clear
use anes_pilot_2018.dta
set more off

***Survey Weights
svyset [pweight=weight]

***Gender
svy: tab gender

***Age
gen age = 2018 - birthyr

gen age_cat = .
	replace age_cat = 1 if age >=18 & age <= 24
	replace age_cat = 2 if age >=25 & age <= 34
	replace age_cat = 3 if age >=35 & age <= 44
	replace age_cat = 4 if age >=45 & age <= 54
	replace age_cat = 5 if age >=55 & age <= 64
	replace age_cat = 6 if age >=65

svy: mean age
svy: tab age_cat

***Education
recode educ (-7 -1 =.) (1=1) (2=2) (3 4 =3) (5=4) (6=5), gen(educ1)
svy: tab educ1

***Race/Ethnicity
recode race (-7 -1 =.) (1=1 "White") (2=2 "Black") (3=3 "Hispanic" ) (4 = 4 "Asian") (5 6 7 = 5 "Other"), gen(race1)
svy: tab race1

***Household Income
recode faminc_new (-7 -1 97 =.), gen(income)

summ income, detail

***PID
recode pid7x (-7 =.), gen(pid)
recode pid (1 2 3 = 1 "Democrat" ) (4=2 "Independent") (5 6 7 = 3 "Republican"), gen(pid_3)

svy: mean pid
svy: tab pid_3


***Symbolic Ideology
recode lcself (-7 -1 =.), gen(ideol)
recode ideol (1 2 3 = 1 "Liberal" ) (4 = 2 "Moderate") (5 6 7 = 3 "Liberal"), gen(ideol_3)

svy: mean ideol
svy: tab ideol_3


log close

